package com.banciyuan.bcywebview.biz.main.message.messagedetail;

import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.factory.MessageFactory;
import com.banciyuan.bcywebview.base.factory.TimelineFactory;
import com.banciyuan.bcywebview.base.helper.data.UserDataHelper;
import com.banciyuan.bcywebview.base.helper.timelinedatacenter.DetailDataHelper;
import com.banciyuan.bcywebview.base.view.toast.MyToast;
import com.banciyuan.bcywebview.biz.ask.AskActivity;
import com.banciyuan.bcywebview.biz.ask.question.QuestionActivity;
import com.banciyuan.bcywebview.biz.detail.comment.DetailCommentActivity;
import com.banciyuan.bcywebview.biz.detail.goods.GoodsDetailActivity;
import com.banciyuan.bcywebview.biz.detail.noveldetail.NovelIndexActivity;
import com.banciyuan.bcywebview.biz.groupdetail.NewTeamDetailActivity;
import com.banciyuan.bcywebview.biz.main.discover.topwork.NovelTopWorkActivity;
import com.banciyuan.bcywebview.biz.main.discover.topwork.TopWorkActivity;
import com.banciyuan.bcywebview.biz.main.mineinfo.mywork.AchievementActivity;
import com.banciyuan.bcywebview.biz.main.mineinfo.reward.MyRewardActivity;
import com.banciyuan.bcywebview.biz.pc.zone.smooth.SmoothPersonActivity;
import com.banciyuan.bcywebview.biz.topic.TopicDetailActivity;
import com.banciyuan.bcywebview.utils.intent.gotoUtil;
import com.banciyuan.bcywebview.utils.string.StringUtil;
import com.banciyuan.bcywebview.utils.universalimageloader.core.ImageLoader;
import com.banciyuan.bcywebview.utils.universalimageloader.utils.ImageOptions;

import java.util.List;

import de.greenrobot.daoexample.model.DetailType;
import de.greenrobot.daoexample.model.Message;

/**
 * Created by hfxt2008 on 14-7-30.
 */
public class MessageListviewAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mInflater;
    private List<Message> mlist;

    public MessageListviewAdapter(Context mContext, List<Message> mlist) {
        this.mContext = mContext;
        this.mlist = mlist;
        this.mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        if (mlist == null) return 0;
        else return mlist.size();
    }

    @Override
    public Object getItem(int postion) {
        return mlist.get(postion);
    }

    @Override
    public long getItemId(int postion) {
        return postion;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder mViewHolder = null;
        Message mItem = mlist.get(position);
        if (convertView == null) {
            mViewHolder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.message_list_item, viewGroup, false);
            mViewHolder.content = (TextView) convertView.findViewById(R.id.message_message_tv);
            mViewHolder.head = (ImageView) convertView.findViewById(R.id.message_head_img);
            mViewHolder.time = (TextView) convertView.findViewById(R.id.message_time_tv);
            convertView.setTag(mViewHolder);
        } else {
            mViewHolder = (ViewHolder) convertView.getTag();
        }

        if (StringUtil.notNullStartWithUrlHead(mItem.getAvatar()))
            ImageLoader.getInstance().displayImage(mItem.getAvatar(), mViewHolder.head, ImageOptions.optionHead);
        else
            mViewHolder.head.setImageDrawable(mContext.getResources().getDrawable(R.drawable.user_pic_big));
        mViewHolder.time.setText(StringUtil.getOppositeTime(mItem.getCtime()));

        StringBuilder mMessage = new StringBuilder();
        int type = MessageFactory.whichType(mItem);
        if (type < 141) {
            if (TextUtils.isEmpty(mItem.getUname()))
                mMessage.append(mContext.getString(R.string.have_person));
            else mMessage.append(mItem.getUname());
        }
        boolean ifReply = false;
        boolean isLock = false;
        boolean isUnLock = false;
        boolean isDiscover = false;
        boolean isSpecial = false;
        boolean isGoods = false;
        boolean isReplyDing = false;
        switch (type) {
            case MessageFactory.MESSAGE_TYPE_FOLLOW:
                mMessage.append(mContext.getString(R.string.focus_you));
                break;
            case MessageFactory.MESSAGE_TYPE_DING:
                mMessage.append(mContext.getString(R.string.paise_your_work));
                break;
            case MessageFactory.MESSAGE_TYPE_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_your_work));
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY_DING:
                mMessage.append(mContext.getString(R.string.paise_your_daily));
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_your_daily));
                break;
            case MessageFactory.MESSAGE_TYPE_ASK_DING:
                mMessage.append(mContext.getString(R.string.paise_your_reply));
                break;
            case MessageFactory.MESSAGE_TYPE_ASK_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_your_reply));
                break;
            case MessageFactory.MESSAGE_TYPE_GROUP_DING:
                mMessage.append(mContext.getString(R.string.paise_your_post));
                break;
            case MessageFactory.MESSAGE_TYPE_GROUP_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_your_post));
                break;
            case MessageFactory.MESSAGE_TYPE_COMMENT:
                mMessage.append(mContext.getString(R.string.reply_your_work));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY_COMMENT:
                mMessage.append(mContext.getString(R.string.reply_your_daily));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_GROUP_COMMENT:
                mMessage.append(mContext.getString(R.string.reply_your_post));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_ASK_ANSWER:
                mMessage.append(mContext.getString(R.string.answer_your_ask));
                break;
            case MessageFactory.MESSAGE_TYPE_ASK_ASK:
            case MessageFactory.MESSAGE_TYPE_ASK_NONAMEASK:
                mMessage.append(mContext.getString(R.string.ask_your_question));
                break;
            case MessageFactory.MESSAGE_TYPE_REPLY:
            case MessageFactory.MESSAGE_TYPE_DAILY_REPLY:
            case MessageFactory.MESSAGE_TYPE_GROUP_REPLY:
                ifReply = true;
                mMessage.append(mContext.getString(R.string.mentioned_you));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_REPLY_DING:
                mMessage.append(mContext.getString(R.string.paise_your_comment));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_NOVEL_SUBSCRIBE:
                mMessage.append(mContext.getString(R.string.book_your_serise));//todo
                break;
            case MessageFactory.MESSAGE_TYPE_NOVEL_UPDATE:
                mMessage.append(mContext.getString(R.string.update_serise));//todo
                break;
            case MessageFactory.MESSATE_TYPE_GROUPTEAM_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_groupteam));
                break;
            case MessageFactory.MESSAGE_TYPE_COSER_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_incos));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_DRAWER_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_indrawer));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_WRITER_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_inwriter));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_indaily));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_GROUPPOST_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_ingrouppost));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_GROUPINTRO_CONTENT:
                mMessage.append(mContext.getString(R.string.mentioned_ingroup));
                ifReply = true;
                break;
            case MessageFactory.MESSAGE_TYPE_TAGGROUPADD_CONTENT:
                mMessage.append(mContext.getString(R.string.addtag_inyourgroup));
                ifReply = true;
                break;
            case MessageFactory.COSER_POST_LOCK:
            case MessageFactory.DRAWER_POST_LOCK:
            case MessageFactory.WRITER_POST_LOCK:
                mMessage.append(mContext.getString(R.string.sorry_your_work));
                isLock = true;
                break;
            case MessageFactory.COSER_POST_UNLOCK:
            case MessageFactory.DRAWER_POST_UNLOCK:
            case MessageFactory.WRITER_POST_UNLOCK:
                mMessage.append(mContext.getString(R.string.cheer_your_work));
                isUnLock = true;
                break;
            case MessageFactory.DAILY_LOCK:
                mMessage.append(mContext.getString(R.string.sorry_your_work_daily));
                isLock = true;
                break;
            case MessageFactory.DAILY_UNLOCK:
                isUnLock = true;
                mMessage.append(mContext.getString(R.string.cheer_your_work_daily));
                break;
            case MessageFactory.SPECIAL:
                isSpecial = true;
                mMessage.append(String.format(mContext.getString(R.string.cheer_topicselect), mItem.getData().getEvent()));
                break;
            case MessageFactory.DISCOVER:
                isDiscover = true;
                mMessage.append(String.format(mContext.getString(R.string.cheer_indexselect), mItem.getData().getEvent()));
                break;
            case MessageFactory.SEND_GIFT:
                mMessage.append(mContext.getString(R.string.rewardyourpost));
                break;
            case MessageFactory.SEND_DAILY_GIFT:
                mMessage.append(mContext.getString(R.string.rewardyourdaily));
                break;
            case MessageFactory.TOP_LIST_COSER:
            case MessageFactory.TOP_LIST_DRAWER:
            case MessageFactory.TOP_LIST_WRITE:
                break;
            case MessageFactory.GROUP_INVITE:
                mMessage.append(mContext.getString(R.string.invited_group));
                break;
            case MessageFactory.CIRCLE_TOP_LIST:
                break;
            case MessageFactory.ZHIPING_TUIJIAN:
                mMessage.append(mContext.getString(R.string.recommend_your_goods));
                appendGoodsName(mItem, mMessage, 10);
                isGoods = true;
                break;
            case MessageFactory.ZHIPING_DING:
                mMessage.append(mContext.getString(R.string.paise_your_goods));
                appendGoodsName(mItem, mMessage, 10);
                isGoods = true;
                break;
            case MessageFactory.ZHIPING_SOLD:
                mMessage.append(mContext.getString(R.string.buy_your_goods));
                break;
            case MessageFactory.ZHIPING_LOCK:
                mMessage.append(mContext.getString(R.string.sorry_your_goods));
                isLock = true;
                break;
            case MessageFactory.ZHIPING_UNLOCK:
                mMessage.append(mContext.getString(R.string.cheer_your_goods));
                isUnLock = true;
                break;
            case MessageFactory.COMMENT_REPLAY_AT_ME:
                mMessage.append(mContext.getString(R.string.at_your_in_comment_reply));
                ifReply = true;
                break;
            case MessageFactory.COMMENT_REPLAY_ME:
                mMessage.append(mContext.getString(R.string.reply_your_comment));
                ifReply = true;
                break;
            case MessageFactory.COSER_COMMENT_DING:
            case MessageFactory.DRAWER_COMMENT_DING:
            case MessageFactory.WRITER_COMMENT_DING:
            case MessageFactory.DAILY_COMMENT_DING:
            case MessageFactory.GROUP_POST_COMMENT_DING:
                mMessage.append(mContext.getString(R.string.ding_your_reply));
                isReplyDing = true;
                break;
            default:
                break;
        }

        if (!ifReply && !isLock && !isUnLock && !isDiscover && !isSpecial && !isGoods && !isReplyDing) {
            String content = mItem.getData().getEvent();
            if (!TextUtils.isEmpty(content)) {
                mMessage.append(content);
            }
        }
        if (isLock || isUnLock) {
            if (type == MessageFactory.DAILY_LOCK || type == MessageFactory.DAILY_UNLOCK) {
                appendLockLetters(mMessage, isLock, true);
            } else if (type == MessageFactory.ZHIPING_LOCK || type == MessageFactory.ZHIPING_UNLOCK) {
                appendZhipinLockLetters(mItem, mMessage, isLock);
            } else {
                appendComplexLockLetters(mItem, mMessage, isLock);
            }
        }
        mViewHolder.content.setText(Html.fromHtml(mMessage.toString()));
        OnClick messageListener = new OnClick(position, StringUtil.notNull(mItem.getType()));
        mViewHolder.content.setOnClickListener(messageListener);
        mViewHolder.time.setOnClickListener(messageListener);
        mViewHolder.head.setOnClickListener(messageListener);
        return convertView;
    }

    private void appendZhipinLockLetters(Message mItem, StringBuilder mMessage, boolean isLock) {
        appendGoodsName(mItem, mMessage, 7);
        appendLockLetters(mMessage, isLock, false);
    }

    private void appendComplexLockLetters(Message mItem, StringBuilder mMessage, boolean isLock) {
        String content = mItem.getData().getEvent();
        if (!TextUtils.isEmpty(content)) {
            if (content.length() > 15) {
                content = content.substring(0, 15);
                content += "...";
                mMessage.append(content);
                appendLockLetters(mMessage, isLock, true);
            } else {
                mMessage.append(content);
                appendLockLetters(mMessage, isLock, true);
            }
        } else {
            appendLockLetters(mMessage, isLock, true);
        }
    }

    private void appendLockLetters(StringBuilder mMessage, boolean isLock, boolean canChange) {
        if (isLock) {
            if (canChange) {
                mMessage.append(mContext.getString(R.string.is_lock));
            } else {
                mMessage.append(mContext.getString(R.string.is_lock_cant_change));
            }
        } else {
            mMessage.append(mContext.getString(R.string.is_unlocked));
        }
    }

    private void appendGoodsName(Message mItem, StringBuilder mMessage, int maxLength) {
        String content = mItem.getData().getEvent();
        if (!TextUtils.isEmpty(content)) {
            if (content.length() > maxLength) {
                content = content.substring(0, maxLength);
                content += "...";
            }
            mMessage.append(String.format(mContext.getString(R.string.message_goodsname_format), content));
        }
    }

    private static class ViewHolder {
        TextView content;
        TextView time;
        ImageView head;
    }

    public void updateData() {
        notifyDataSetChanged();
    }

    class OnClick implements OnClickListener {

        Message mItem;
        String type;

        public OnClick(int position, String type) {
            mItem = (Message) getItem(position);
            this.type = type;

        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.message_head_img:
                    if (!TextUtils.isEmpty(mItem.getUname())) {
                        gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getFrom());
                        break;
                    } else {
                        goDetail(type, mItem);
                        break;
                    }
                case R.id.message_message_tv:
                case R.id.message_time_tv:
                    goDetail(type, mItem);
                default:
                    break;
            }
        }
    }

    private void goDetail(String type, Message mItem) {
        int messageType = MessageFactory.inWhichType(type);
        switch (messageType) {
            case MessageFactory.MESSAGE_TYPE_FOLLOW:
                gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getFrom());
                break;
            case MessageFactory.MESSAGE_TYPE_ILL:
            case MessageFactory.MESSAGE_TYPE_COS:
            case MessageFactory.MESSAGE_TYPE_DAILY:
            case MessageFactory.MESSAGE_TYPE_GROUP:
                switch (MessageFactory.whichType(mItem)) {
                    case MessageFactory.MESSAGE_TYPE_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_DAILY_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_GROUP_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_REPLY:
                    case MessageFactory.MESSAGE_TYPE_DAILY_REPLY:
                    case MessageFactory.MESSAGE_TYPE_GROUP_REPLY:
                    case MessageFactory.MESSAGE_TYPE_REPLY_DING:
                        processMessageDetailData(mItem, messageType, true, true);
                        break;
                    case MessageFactory.COMMENT_REPLAY_AT_ME:
                    case MessageFactory.COMMENT_REPLAY_ME:
                        goCommnetReplay(mItem.getData().getReply_id(), mItem, messageType);
                        break;
                    default:
                        processMessageDetailData(mItem, messageType, false, false);
                        break;

                }
                break;
            case MessageFactory.MESSAGE_TYPE_WRITER:
                switch (MessageFactory.whichType(mItem)) {
                    case MessageFactory.MESSAGE_TYPE_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_DAILY_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_GROUP_COMMENT:
                    case MessageFactory.MESSAGE_TYPE_REPLY:
                    case MessageFactory.MESSAGE_TYPE_DAILY_REPLY:
                    case MessageFactory.MESSAGE_TYPE_GROUP_REPLY:
                    case MessageFactory.MESSAGE_TYPE_REPLY_DING:
                        DetailDataHelper.gotoWriterDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getWp_id(), true, true);
                        break;
                    case MessageFactory.MESSAGE_TYPE_NOVEL_SUBSCRIBE:
                    case MessageFactory.MESSAGE_TYPE_NOVEL_UPDATE:
                        gotoUtil.gotoAct(mContext, NovelIndexActivity.class, mItem.getData().getWns_id());
                        break;
                    case MessageFactory.COMMENT_REPLAY_AT_ME:
                    case MessageFactory.COMMENT_REPLAY_ME:
                        goCommnetReplay(mItem.getData().getReply_id(), mItem, MessageFactory.MESSAGE_TYPE_WRITER);
                        break;
                    default:
                        DetailDataHelper.gotoWriterDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getWp_id(), false);
                        break;
                }
                break;
            case MessageFactory.MESSAGE_TYPE_ASK:
                gotoUtil.gotoAct(mContext, AskActivity.class, mItem.getFrom(), mItem.getData().getOuname());
                break;
            case MessageFactory.MESSAGE_TYPE_ASK_SELF:
                gotoUtil.gotoAct(mContext, AskActivity.class, UserDataHelper.getInstance(mContext).getUid(),
                        UserDataHelper.getInstance(mContext).getUname());
                break;
            case MessageFactory.MESSAGE_TYPE_ASKED:
                gotoUtil.gotoAct(mContext, QuestionActivity.class);
                break;
            case MessageFactory.MESSATE_TYPE_GROUPTEAM:
            case MessageFactory.MESSAGE_TYPE_GROUPINTRO_CONTENT:
            case MessageFactory.MESSAGE_TYPE_TAGGROUPADD_CONTENT:
                gotoUtil.gotoAct(mContext, NewTeamDetailActivity.class, mItem.getData().getGid());
                break;
            case MessageFactory.MESSAGE_TYPE_COSER_CONTENT:
                DetailDataHelper.gotoCosDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getCp_id(), false);
                break;
            case MessageFactory.MESSAGE_TYPE_DRAWER_CONTENT:
                DetailDataHelper.gotoDrawerDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getDp_id(), false);
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY_CONTENT:
                DetailDataHelper.gotoDailyDetail(mContext, mItem.getData().getUd_id(), false);
                break;
            case MessageFactory.MESSAGE_TYPE_GROUPPOST_CONTENT:
                DetailDataHelper.gotoGroupDetail(mContext, mItem.getData().getGid(), mItem.getData().getPost_id(), false);
                break;
            case MessageFactory.MESSAGE_TYPE_WRITER_CONTENT:
                DetailDataHelper.gotoWriterDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getWp_id(), false);
                break;
            case MessageFactory.COSER_POST_UNLOCK:
            case MessageFactory.COSER_POST_LOCK:
                DetailDataHelper.gotoCosDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getCp_id(), false);
                break;
            case MessageFactory.DRAWER_POST_UNLOCK:
            case MessageFactory.DRAWER_POST_LOCK:
                DetailDataHelper.gotoDrawerDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getDp_id(), false);
                break;
            case MessageFactory.DAILY_LOCK:
            case MessageFactory.DAILY_UNLOCK:
                DetailDataHelper.gotoDailyDetail(mContext, mItem.getData().getUd_id(), false);
                break;
            case MessageFactory.WRITER_POST_UNLOCK:
            case MessageFactory.WRITER_POST_LOCK:
                DetailDataHelper.gotoWriterDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getWp_id(), false);
                break;
            case MessageFactory.SPECIAL:
                gotoUtil.gotoAct(mContext, TopicDetailActivity.class, Integer.parseInt(mItem.getData().getSpecial_id()));
                break;
            case MessageFactory.SEND_GIFT:
            case MessageFactory.SEND_DAILY_GIFT:
                gotoUtil.gotoAct(mContext, MyRewardActivity.class, 1);
                break;
            case MessageFactory.TOP_LIST_COSER:
                gotoUtil.gotoAct(mContext, TopWorkActivity.class, 0, mItem.getData().getSub_type(), mItem.getData().getDate());
                break;
            case MessageFactory.TOP_LIST_DRAWER:
                gotoUtil.gotoAct(mContext, TopWorkActivity.class, 1, mItem.getData().getSub_type(), mItem.getData().getDate());
                break;
            case MessageFactory.TOP_LIST_WRITE:
                gotoUtil.gotoAct(mContext, NovelTopWorkActivity.class, 2, mItem.getData().getSub_type(), mItem.getData().getDate());
                break;
            case MessageFactory.GROUP_INVITE:
                gotoUtil.gotoAct(mContext, NewTeamDetailActivity.class, mItem.getData().getGid());
                break;
            case MessageFactory.CIRCLE_TOP_LIST:
                gotoUtil.gotoAct(mContext, AchievementActivity.class);
                break;
            case MessageFactory.ZHIPING_TUIJIAN:
            case MessageFactory.ZHIPING_DING:
            case MessageFactory.ZHIPING_LOCK:
            case MessageFactory.ZHIPING_UNLOCK:
                gotoUtil.gotoAct(mContext, GoodsDetailActivity.class, mItem.getData().getZg_id());
                break;
            case MessageFactory.ZHIPING_SOLD:
                MyToast.show(mContext, mContext.getString(R.string.visit_on_web));
                break;
            case MessageFactory.COSER_COMMENT_DING:
            case MessageFactory.DRAWER_COMMENT_DING:
            case MessageFactory.WRITER_COMMENT_DING:
            case MessageFactory.DAILY_COMMENT_DING:
            case MessageFactory.GROUP_POST_COMMENT_DING:
                goCommnetReplay(mItem.getData().getReply_id(), mItem, messageType);
                break;
            default:
                break;
        }
    }

    private void processMessageDetailData(Message mItem, int messageType, boolean fromComment, boolean goComment) {
        switch (messageType) {
            case MessageFactory.MESSAGE_TYPE_COS:
                DetailDataHelper.gotoCosDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getCp_id(), fromComment, goComment);
                break;
            case MessageFactory.MESSAGE_TYPE_ILL:
                DetailDataHelper.gotoDrawerDetail(mContext, mItem.getData().getRp_id(), mItem.getData().getDp_id(), fromComment, goComment);
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY:
                DetailDataHelper.gotoDailyDetail(mContext, mItem.getData().getUd_id(), fromComment, goComment);
                break;
            case MessageFactory.MESSAGE_TYPE_GROUP:
                DetailDataHelper.gotoGroupDetail(mContext, mItem.getData().getGid(), mItem.getData().getPost_id(), fromComment, goComment);
                break;
        }
    }

    private void goCommnetReplay(String commnetId, Message message, int type) {
        DetailType detailType = new DetailType();
        switch (type) {
            case MessageFactory.MESSAGE_TYPE_COS:
            case MessageFactory.COSER_COMMENT_DING:
                detailType.setRp_id(message.getData().getRp_id());
                detailType.setCp_id(message.getData().getCp_id());
                detailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_COSER);
                break;
            case MessageFactory.MESSAGE_TYPE_ILL:
            case MessageFactory.DRAWER_COMMENT_DING:
                detailType.setRp_id(message.getData().getRp_id());
                detailType.setDp_id(message.getData().getDp_id());
                detailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_ILLUST);
                break;
            case MessageFactory.MESSAGE_TYPE_WRITER:
            case MessageFactory.WRITER_COMMENT_DING:
                detailType.setRp_id(message.getData().getRp_id());
                detailType.setWp_id(message.getData().getWp_id());
                detailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_WRITER);
                break;
            case MessageFactory.MESSAGE_TYPE_DAILY:
            case MessageFactory.DAILY_COMMENT_DING:
                detailType.setUd_id(message.getData().getUd_id());
                detailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_DAILY);
                break;
            case MessageFactory.MESSAGE_TYPE_GROUP:
            case MessageFactory.GROUP_POST_COMMENT_DING:
                detailType.setGid(message.getData().getGid());
                detailType.setPost_id(message.getData().getPost_id());
                detailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_GROUP);
                break;
        }
        Intent intent = new Intent(mContext, DetailCommentActivity.class);
        intent.putExtra(gotoUtil.INTENT_VALUE_ONE, commnetId);
        intent.putExtra(gotoUtil.INTENT_VALUE_TWO, detailType);
        intent.putExtra(gotoUtil.INTENT_VALUE_THREE, true);
        mContext.startActivity(intent);
    }

}